import InventoryEngine.SCUMMInventoryItem;

class InventoryEngine.SCUMMInventory{
	private var a_Items:Array;
	private var i_index:Number;
	private var mc:MovieClip;
	public function SCUMMInventory(po_mc:MovieClip) {
		this.mc = po_mc;
		this.i_index=0;
		this.a_Items = new Array();
		
	}
	public function addItem(po_ii:SCUMMInventoryItem) {
		this.a_Items.push(po_ii.index);
		this.reDraw();
	}
	
	public function removeItem(po_ii:SCUMMInventoryItem){
		this.a_Items.splice(po_ii.index, 1);
	}
	
	private function reDraw() {
		var itemContainerIndex:Number;
			if(this.a_Items[i_index]){
			for (itemContainerIndex = i_index; itemContainerIndex < (i_index+12); itemContainerIndex++) {
				if(this.a_Items[itemContainerIndex]){
					this.mc["cell"+(itemContainerIndex-i_index)].gotoAndStop(this.a_Items[itemContainerIndex]);
				}else{
					this.mc["cell"+(itemContainerIndex-i_index)].gotoAndStop(1);
				}
			}
		}
	}
	
	public function pageDown(){
		if(this.a_Items[this.i_index+12]){
			this.i_index+=6;
		}
		this.reDraw();
	}
	
	public function pageUp(){
		if((this.i_index-6)>=0){
			this.i_index-=6;
		}
		this.reDraw();
	}
	
}